import Taro, { Component } from '@tarojs/taro'
import { AtButton } from 'taro-ui'
import classnames from 'classnames'
import PropsType from 'prop-types'
import { View, Text, Image } from '@tarojs/components'
import '../styles/iteminformation.scss'
const itementerprise = require('./itementerprise.png')
const itemuser = require('./itemuser.png')

export default class DInformation extends Component {

    onHandleClick() {
        this.props.onHandleClick && this.props.onHandleClick()
    }

    render() {
        const {
            className,
            title,
            status,
            list,
            text,
            isClick
        } = this.props
        return (
            <View className={classnames('b_iteminformation', className)}>
                <View className='b_iteminformation__header'>
                    <View className='b_iteminformation__header_name'>
                        <Image src={title === '企业认证' ? itementerprise : itemuser} className='item_img'></Image>
                        <Text className='item_text'>{title}</Text>
                    </View>
                    {
                        status && <View className='b_iteminformation__header_status'>{status}</View>
                    }
                </View>
                <View className='b_iteminformation__content'>
                    {
                        list.map((item, i) => {
                            return <View key={i} className='item_list'>{item}</View>
                        })
                    }
                </View>
                <AtButton className={classnames('item_btn', isClick === '2' ?'item_btn_no':'')} onClick={this.onHandleClick.bind(this)}>{text}</AtButton>
            </View>
        )
    }
}

DInformation.defaultProps = {
    className: '',
    title: '',
    status: '',
    list: [],
    text: '',
    onHandleClick: () => { }
}

DInformation.PropsType = {
    className: PropsType.oneOfType[PropsType.string, PropsType.object],
    title: PropsType.string,
    status: PropsType.string,
    list: PropsType.array,
    text: PropsType.string,
    onHandleClick: PropsType.func
}